package com.scsj.supermarket.view.activity.shopmodel;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.scsj.supermarket.R;
import com.scsj.supermarket.adapter.ShopBrandAdapter;
import com.scsj.supermarket.customview.GridSpacingItemDecoration;
import com.scsj.supermarket.utils.SkipUtils;
import com.scsj.supermarket.view.activity.baseactivitymodel.BaseActivity;
import com.vondear.rxtools.RxImageTool;
import com.vondear.rxtools.view.dialog.RxDialogSureCancel;

import java.util.ArrayList;
import java.util.List;


/**
 * 店铺详情
 */
public class ShopDetailsActivity extends BaseActivity implements View.OnClickListener {

    private LinearLayout shop_follow_ll;
    private LinearLayout tab_one, tab_two, tab_three, tab_four;
    private LinearLayout qrcode_ll, certificate_ll;
    private RecyclerView brand_recyclerview;//品牌列表
    private ShopBrandAdapter shopBrandAdapter;
    private LinearLayout brand_more;
    private TextView contact_seller_tv, making_calls;

    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_shop_details);
        initToolbar();
        setToolbarTitle("店铺详情");
        hasBack(true);
    }

    @Override
    protected void initView() {
        shop_follow_ll = findViewById(R.id.shop_follow_ll);//关注
        tab_one = findViewById(R.id.tab_one);//首页
        tab_two = findViewById(R.id.tab_two);//全部商品
        tab_three = findViewById(R.id.tab_three);//积分购
        tab_four = findViewById(R.id.tab_four);//分享购
        qrcode_ll = findViewById(R.id.qrcode_ll);//二维码
        certificate_ll = findViewById(R.id.certificate_ll);//证照信息

        brand_recyclerview = findViewById(R.id.brand_recyclerview);//品牌列表
        brand_recyclerview.setLayoutManager(new GridLayoutManager(this, 2) {
            @Override
            public boolean canScrollVertically() {
                return false;
            }
        });
        brand_recyclerview.addItemDecoration(new GridSpacingItemDecoration(2, RxImageTool.dp2px(10), true));
        brand_more = findViewById(R.id.brand_more);//更多品牌
        contact_seller_tv = findViewById(R.id.contact_seller_tv);//联系卖家
        making_calls = findViewById(R.id.making_calls);//拨打电话

    }

    @Override
    protected void initListener() {
        shop_follow_ll.setOnClickListener(this);
        tab_one.setOnClickListener(this);
        tab_two.setOnClickListener(this);
        tab_three.setOnClickListener(this);
        tab_four.setOnClickListener(this);
        qrcode_ll.setOnClickListener(this);
        certificate_ll.setOnClickListener(this);
        brand_more.setOnClickListener(this);
        contact_seller_tv.setOnClickListener(this);
        making_calls.setOnClickListener(this);
    }

    @Override
    protected void initData() {
        List<String> list = new ArrayList<>();
        list.add("长城（GreatWall");
        list.add("解百纳赤霞珠干红葡萄酒红葡萄酒红葡萄酒");
        list.add("长城（GreatWall");
        list.add("解百纳赤霞珠干红葡萄酒红葡萄酒红葡萄酒");
        shopBrandAdapter = new ShopBrandAdapter(list);
        brand_recyclerview.setAdapter(shopBrandAdapter);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.shop_follow_ll:
                shop_follow_ll.setBackgroundResource(R.mipmap.shop_details_follow);
//                shop_follow_ll.setBackgroundResource(R.mipmap.shop_details_unfollow);
                break;
            case R.id.tab_one:
                finish();
                break;
            case R.id.tab_two:
                finish();
                break;
            case R.id.tab_three:
                finish();
                break;
            case R.id.tab_four:
                finish();
                break;

            case R.id.brand_more://更多品牌
                SkipUtils.toAllBrand(this);
                break;

            case R.id.making_calls://拨打电话
                final RxDialogSureCancel rxDialogSureCancel = new RxDialogSureCancel(this);//提示弹窗
                rxDialogSureCancel.setContent("13013013013");
                rxDialogSureCancel.setSure("取消");
                rxDialogSureCancel.setSureListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        rxDialogSureCancel.cancel();
                    }
                });
                rxDialogSureCancel.setCancel("拨打");
                rxDialogSureCancel.setCancelListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        rxDialogSureCancel.cancel();
                    }
                });
                rxDialogSureCancel.show();
                break;
            default:
                break;
        }
    }
}
